import 'package:flutter/material.dart';

import 'route_params.dart';
import 'routes_name.dart';

class RouteTestPage extends StatefulWidget {
  final RouteParams routeParams;

  const RouteTestPage({Key key, this.routeParams,}) : super(key: key);

  @override
  _RouteTestPageState createState() => _RouteTestPageState();
}

class _RouteTestPageState extends State<RouteTestPage> {
  String text;

  @override
  void initState() {
    RouteParams params = widget.routeParams;
    print("params.toString() == ${params.toString()}");
    text = params.toString();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    /*获取传递过来的参数*/
    return Scaffold(
      appBar: AppBar(title: Text("route test page1")),
      body: Container(
        child: Column(
          children: [
            Text("aaa"),
            RaisedButton(
                onPressed: () {
                  Navigator.of(context).pushNamed(RoutesName.ROUTE_TEST_PAGE2, arguments: RouteParams(param1: "1aaa"));
                },
                child: Text("push ${RoutesName.ROUTE_TEST_PAGE2}, text = ${text ?? ""}"))
          ],
        ),
      ),
    );
  }
}
